Attribute VB_Name = "Module1"
Option Explicit
Sub PrintSheetAsPDFwithBullZip()
'must add a reference to BullZip
    Dim myobject As New Bullzip.PDFPrinterSettings
    Dim SavePath As String, FileName As String
	' Late binding
	' Set myobject = CreateObject("Bullzip.PDFPrinterSettings")
    SavePath = Environ("HOMEDRIVE") & Environ("HOMEPATH") & "\Download\"
    FileName = InputBox("Save PDF to desktop as:", "Sheet '" & ActiveSheet.Name & "' to PDF...", ActiveSheet.Name)
    If LCase(Right(FileName, 4)) <> ".pdf" Then FileName = FileName & ".pdf"
    'see default settings in
    'Environ("HOMEDRIVE") & Environ("APPDATA") & "\Bullzip\PDF Printer\settings.ini"
    myobject.SetValue "output", SavePath & FileName
    myobject.SetValue "showsettings", "never"
    myobject.WriteSettings (True)    'writes the settings in a runonce.ini that it immediately deleted after being used.

    'change to bullzip printer...
    If InStr(ActivePrinter, "BullZip") = 0 Then
        Dim storeprinter$, PrinterChanged As Boolean
        PrinterChanged = True
        storeprinter = ActivePrinter
        ActivePrinter = GetFullNetworkPrinterName("Bullzip PDF Printer")
    End If
    ActiveSheet.PrintOut
    If PrinterChanged Then ActivePrinter = storeprinter
End Sub

'the following code is from http://www.erlandsendata.no/english/ind ... ngeprinter
Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
' returns the full network printer name
' returns an empty string if the printer is not found
' e.g. GetFullNetworkPrinterName("HP LaserJet 8100 Series PCL")
' might return "HP LaserJet 8100 Series PCL on Ne04:"
    Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
    strCurrentPrinterName = Application.ActivePrinter
    i = 0
    Do While i < 100
        strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
        On Error Resume Next    ' try to change to the network printer
        Application.ActivePrinter = strTempPrinterName
        On Error GoTo 0
        If Application.ActivePrinter = strTempPrinterName Then
            ' the network printer was found
            GetFullNetworkPrinterName = strTempPrinterName
            i = 100    ' makes the loop end
        End If
        i = i + 1
    Loop
    ' remove the line below if you want the function to change the active printer
    Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function
'' ------------------------------------------  Sample Code 2  -------------------------------------------------
Function PrintSheetAsPDF(file_name As String, merge_file_name As String, doc_title As String, author As String, save_path As String, subject_name As String, keywords As String, filetype As String)
    Dim obj_printer_util As Object
    Dim obj_printer_settings As Object
    Dim current_printer As String
    Dim printername As String
    Dim full_printer_name As String

    Rem -- Get default printer name
    Set obj_printer_util = CreateObject("Bullzip.PDFUtil")
    printername = obj_printer_util.defaultprintername
    Rem -- Create the object to control the printer settings
    Set obj_printer_settings = CreateObject("Bullzip.PDFSettings")
    obj_printer_settings.printername = obj_printer_util.defaultprintername
    obj_printer_settings.LoadSettings (True)

    Rem -- Get the full name of the printer
    full_printer_name = printername
    full_printer_name = GetFullNetworkPrinterName(full_printer_name)

    Rem -- Prompt the user for a file name
    ' file_name = InputBox("Save PDF to desktop as:", "Sheet '" & _
      ' ActiveSheet.Name & "' to PDF...", ActiveSheet.Name)

    Rem -- Abort the process if the user cancels the dialog
    If file_name = "" Then Exit Function
    Rem -- Make sure that the file name ends with .pdf
    If LCase(Right(file_name, 4)) <> ".pdf" Then
        file_name = file_name & ".pdf"
    End If

    Rem -- Write the settings to the printer
    Rem -- Settings are written to the runonce.ini
    Rem -- This file is deleted immediately after being used.
    With obj_printer_settings
        .SetValue "output", save_path & file_name
        .SetValue "showsettings", "never"
        .SetValue "ConfirmOverwrite", "no"
        .SetValue "ShowPDF", "no"
        .SetValue "Target", "prepress"
        .SetValue "Author", author
        .SetValue "Title", doc_title
        .SetValue "Subject", subject_name
        .SetValue "Keywords", keywords
        .SetValue "UseThumbs", "no"
        .SetValue "AutoRotatePages", "all"
        .SetValue "Linearize", "yes"
        .SetValue "Res", "3600"
        If merge_file_name <> "" Then
            .SetValue "MergeFile", save_path & merge_file_name
            .SetValue "MergePosition", "bottom"
        End If
        If filetype = "JPEG" Then
            .SetValue "Device", "jpeg"
        End If
        .WriteSettings True
    End With

    Rem -- Change to PDF printer
    current_printer = ActivePrinter
    ActivePrinter = full_printer_name

    Rem -- Print the active work sheet
    ActiveSheet.PrintOut

    Rem -- Restore the printer selection
    ActivePrinter = current_printer
End Function